<template>
  <div>
    <x-Table
        :loading="loading"
        :table-data="tableData"
        :options-data="options"
        :rule-form="ruleForms"
        :pagination="pagination"
        @handleAdd="handleAdd"
        @handlePaginationCurrentChange="handlePaginationCurrentChange"
        @handlePaginationSizeChange="handlePaginationSizeChange"
        @handleHeardDel="handleHeardDel"
        @searchForm="searchForm"
        @resetForm="resetForm"
    >
    </x-Table>
    <!--    弹窗区域-->
    <el-dialog
        v-dialog-drag
        :title="alertTitle"
        :visible.sync="dialogVisible"
        :close-on-click-modal="false"
        width="45%"
    >
      <form-create
          v-model="fapi"
          :rule="rule"
          :option="option"
          :value.sync="formParam"
          @submit="onSubmit"
      >
        <!--        课程分页-->
        <template slot="type-page-select-class">
          <el-select :loading="selectClass" @clear="classClear" :remote-method="classFilterMethod" remote
                     filterable
                     v-model="rule[0]['value']"
                     clearable placeholder="请选择">
            <el-option
                style='width: 260px;text-align: center'
                v-for="item in rule[0]['options']"
                :key="item.id"
                :label="item.title  "
                :value="item.id">
            </el-option>
            <el-pagination
                @current-change="classCurrentChange"
                small
                layout="prev, pager, next"
                :page-size="20"
                :current-page="pageSizes.classPage.currentPage"
                :total="pageSizes.classPage.total">
            </el-pagination>
          </el-select>
        </template>
        <!--        end-->

        <!--        试卷分页-->
        <template slot="type-page-select-paper">
          <el-select @change="pagerSelect" :loading="selectPaper" @clear="paperClear" :remote-method="paperFilterMethod"
                     remote
                     filterable
                     v-model="rule[1]['value']"
                     clearable placeholder="请选择">
            <el-option
                style='width: 260px;text-align: center'
                v-for="item in rule[1]['options']"
                :key="item.id"
                :label="item.title  "
                :value="item.id">
            </el-option>
            <el-pagination
                @current-change="paperCurrentChange"
                small
                layout="prev, pager, next"
                :page-size="20"
                :current-page="pageSizes.paperPage.currentPage"
                :total="pageSizes.paperPage.total">
            </el-pagination>
          </el-select>
        </template>
        <!--        end-->
      </form-create>
    </el-dialog>
    <!--    end-->

    <!--    预览试题-->
    <el-dialog
        v-dialog-drag
        title="预览题目"
        :visible.sync="previewExam"
        :close-on-click-modal="false"
        width="65%"
    >
      <preview :perViewData="perViewData"/>
    </el-dialog>

    <!--    end-->

  </div>
</template>

<script>
import preview from './components/previewExam'

let _this = null;
export default {
  components: {preview},
  data() {
    return {
      perViewData: {},//题目数据
      previewExam: false,//预览试题
      searchParams: {},//搜索对象
      selectClass: true,
      selectPaper: true,
      pageSizes: {
        classPage: {
          currentPage: 1,
          total: 0,
        },//课程分页参数
        paperPage: {
          currentPage: 1,
          total: 0,
        },//试卷分页参数
      },
      fapi: {},
      formParam: {},
      rule: [
        {
          "type": "pageSelectClass",
          "field": "class_id",
          "title": "课程名称",
          "info": "",
          "options": [],
          "hidden": false,
          "display": true,
          "value": '',
          "validate": [
            {
              "trigger": "submit",
              "mode": "required",
              "message": "请选择课程",
              "required": true,
              "type": 'number'
            },

          ]
        },
        {
          "type": "pageSelectPaper",
          "field": "paper_id",
          "title": "试卷名称",
          "info": "",
          "effect": {
            "fetch": ""
          },
          "options": [],
          "_fc_drag_tag": "select",
          "hidden": false,
          "display": true,
          "validate": [
            {
              "trigger": "submit",
              "mode": "required",
              "message": "请选择课程",
              "required": true,
              "type": 'number'
            },
          ]
        },
        {
          "type": "switch",
          "field": "status",
          "title": "状态",
          "info": "",
          "_fc_drag_tag": "switch",
          "hidden": false,
          "display": true
        },
        {
          "type": "FcRow",
          "children": [
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "input",
                  "field": "title",
                  "title": "考试名称",
                  "info": "",
                  "_fc_drag_tag": "input",
                  "hidden": false,
                  "display": true,
                  "validate": [
                    {
                      "type": "string",
                      "trigger": "submit",
                      "mode": "required",
                      "message": "请输入考试名称",
                      "required": true
                    }
                  ]
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "inputNumber",
                  "field": "total_score",
                  "title": "总分",
                  "info": "选择试卷自动计算",
                  "_fc_drag_tag": "inputNumber",
                  "hidden": false,
                  "display": true,
                  props: {
                    "min": 0,
                    "disabled": true
                  },
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "inputNumber",
                  "field": "pass_score",
                  "title": "及格分数",
                  "info": "",
                  "_fc_drag_tag": "inputNumber",
                  "hidden": false,
                  "display": true,
                  props: {
                    "min": 0
                  },
                  "validate": [
                    {
                      "type": "number",
                      "trigger": "submit",
                      "mode": "required",
                      "message": "请输入及格分数",
                      "required": true
                    }
                  ]
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "inputNumber",
                  "field": "duration",
                  "title": "考试时长(分)",
                  "info": "",
                  "props": {
                    "min": 30,
                    "controlsPosition": "default"
                  },
                  "_fc_drag_tag": "inputNumber",
                  "hidden": false,
                  "display": true,
                  "value": 30,
                  "validate": [
                    {
                      "trigger": "submit",
                      "mode": "required",
                      "message": "",
                      "required": true,
                      "type": "number"
                    }
                  ]
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "select",
                  "field": "pattern",
                  "title": "类型",
                  "info": "",
                  "effect": {
                    "fetch": ""
                  },
                  on: {
                    change(e) {
                      _this.setFormDisplay(e)
                    }
                  },
                  "options": [
                    {
                      "value": '考试',
                      "label": "考试"
                    },
                    {
                      "value": '作业',
                      "label": "作业"
                    }
                  ],
                  "_fc_drag_tag": "select",
                  "hidden": false,
                  "display": true,
                  "value": '考试',
                  "validate": [
                    {
                      "trigger": "submit",
                      "mode": "required",
                      "message": "请选择类型",
                      "required": true,
                      "type": "string"
                    }
                  ]
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "inputNumber",
                  "field": "exam_num",
                  "title": "考试次数",
                  "info": "",
                  "_fc_drag_tag": "inputNumber",
                  "hidden": false,
                  "display": true,
                  props: {
                    "min": 1
                  },
                  "validate": [
                    {
                      "type": "number",
                      "trigger": "submit",
                      "mode": "required",
                      "message": "请选择考试次数",
                      "required": true
                    }
                  ]
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "switch",
                  "field": "face",
                  "title": "人脸识别",
                  "info": "",
                  "_fc_drag_tag": "switch",
                  "hidden": false,
                  "display": true,
                  "value": false
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "switch",
                  "field": "video_monitor",
                  "title": "视频监控",
                  "info": "",
                  "_fc_drag_tag": "switch",
                  "hidden": false,
                  "display": true,
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "radio",
                  "field": "exam_model",
                  "title": "考试模式",
                  "info": "任意时间是指开始时间到结束时间都可以进行考试，同时进行是指必须在规定时间开始考试，规定时间交卷",
                  "effect": {
                    "fetch": ""
                  },
                  "options": [
                    {
                      "value": true,
                      "label": "任意时间"
                    },
                    {
                      "value": false,
                      "label": "同时进行"
                    }
                  ],
                  "_fc_drag_tag": "radio",
                  "hidden": false,
                  "display": true,
                  "value": true
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "switch",
                  "field": "exam_tian",
                  "title": "人工阅卷",
                  "info": "填空题是否人工批改试卷",
                  "_fc_drag_tag": "switch",
                  "hidden": false,
                  "display": true
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            }
          ],
          "_fc_drag_tag": "row",
          "hidden": false,
          "display": true
        },
        {
          "type": "FcRow",
          "children": [
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "switch",
                  "field": "chop_screen",
                  "title": "切屏监控",
                  "info": "",
                  "_fc_drag_tag": "switch",
                  "hidden": false,
                  "display": true,
                  on: {
                    change: () => {
                      let screen_num = _this.fapi.getRule('screen_num');
                      screen_num.props.disabled = !_this.fapi.getValue('chop_screen');
                    }
                  }
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "inputNumber",
                  "field": "screen_num",
                  "title": "切屏数量",
                  "info": "",
                  "props": {
                    "min": 1,
                    "disabled": true
                  },
                  "_fc_drag_tag": "inputNumber",
                  "hidden": false,
                  "display": true,
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "switch",
                  "field": "exam_late",
                  "title": "迟到限制",
                  "info": "",
                  "_fc_drag_tag": "switch",
                  "hidden": false,
                  "display": true,
                  "value": false,
                  on: {
                    change: () => {
                      let late_time = _this.fapi.getRule('late_time');
                      late_time.props.disabled = !_this.fapi.getValue('exam_late');
                    }
                  }
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "inputNumber",
                  "field": "late_time",
                  "title": "迟到最晚时间",
                  "info": "",
                  "props": {
                    "min": 5,
                    "disabled": true
                  },
                  "_fc_drag_tag": "inputNumber",
                  "hidden": false,
                  "display": true
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "switch",
                  "field": "exam_shor",
                  "title": "交卷时间控制",
                  "info": "",
                  "_fc_drag_tag": "switch",
                  "hidden": false,
                  "display": true,
                  on: {
                    change: () => {
                      let shor_time = _this.fapi.getRule('shor_time');
                      shor_time.props.disabled = !_this.fapi.getValue('exam_shor');
                    }
                  }
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "inputNumber",
                  "field": "shor_time",
                  "title": "多少分钟交卷",
                  "info": "最快多久能交卷一般为30分钟",
                  "props": {
                    "min": 15,
                    "disabled": true
                  },
                  "_fc_drag_tag": "inputNumber",
                  "hidden": false,
                  "display": true
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            }
          ],
          "_fc_drag_tag": "row",
          "hidden": false,
          "display": true
        },
        {
          "type": "FcRow",
          "children": [
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "datePicker",
                  "field": "start_time",
                  "title": "考试开始时间",
                  "info": "",
                  "props": {
                    "type": "datetime"
                  },
                  "_fc_drag_tag": "datePicker",
                  "hidden": false,
                  "display": true,
                  "validate": [
                    {
                      "trigger": "change",
                      "mode": "required",
                      "message": "请选择开课时间",
                      "required": true,
                      "type": "string"
                    }
                  ]
                },
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            },
            {
              "type": "col",
              "props": {
                "span": 12
              },
              "children": [
                {
                  "type": "datePicker",
                  "field": "end_time",
                  "title": "考试结束时间",
                  "info": "",
                  "props": {
                    "type": "datetime"
                  },
                  "_fc_drag_tag": "datePicker",
                  "hidden": false,
                  "display": true,
                  "validate": [
                    {
                      "trigger": "submit",
                      "mode": "required",
                      "message": "请选择开始考试时间",
                      "required": true,
                      "type": "string"
                    }
                  ]
                }
              ],
              "_fc_drag_tag": "col",
              "hidden": false,
              "display": true
            }
          ],
          "_fc_drag_tag": "row",
          "hidden": false,
          "display": true
        }],
      row: [],
      option: {
        form: {
          inline: false,
          labelPosition: "right",
          size: "small",
          labelWidth: "125px",
          hideRequiredAsterisk: false,
          showMessage: true,
          inlineMessage: false,
        },
        resetBtn: true,
      },
      dialogVisible: false,
      alertTitle: "添加",
      tableData: [],
      loading: true,
      pagination: {
        currentPage: 1,
        pageSize: 20,
        pageSizes: [10, 20, 50, 100],
      }, //分页参数
      ruleForms: {
        title: {label: "考试名称", prop: "title", type: "text"},
        pattern: {
          label: "类型",
          prop: "pattern",
          type: "select",
          select: [{label: '考试', value: '1'}, {label: '作业', value: '0'}]
        },
      },
      options: {
        fields: {
          id: {label: "考试批次", prop: "id", width: "80"},
          class_id: {label: "课程名称", prop: "class_id", type: 'two', options: {obj: 'OfficeClass', objKey: 'title'}},
          paper_id: {label: "试卷名称", prop: "paper_id", type: 'two', options: {obj: 'paper', objKey: 'title'}},
          title: {label: "考试名称", prop: "title",},
          face: {
            label: "人脸识别",
            prop: "face",
            type: "switch",
            activeValue: true,
            inactiveValue: false,
            switchChage: function (scope) {
            },
          },
          video_monitor: {
            label: "视频监控",
            prop: "video_monitor",
            type: "switch",
            activeValue: true,
            inactiveValue: false,
            switchChage: function (scope) {
            },
          },
          exam_model: {
            label: "考试模式",
            prop: "exam_model",
            type: "switch",
            activeValue: true,
            inactiveValue: false,
            switchChage: function (scope) {
            },
          },
          pass_score: {label: "及格分数", prop: "pass_score"},
          duration: {label: "考试时长(分)", prop: "duration"},
          pattern: {label: "类型", prop: "pattern"},
          exam_num: {label: "考试次数", prop: "exam_num"},
          chop_screen: {
            label: "切屏监控",
            prop: "chop_screen",
            type: "switch",
            activeValue: true,
            inactiveValue: false,
            switchChage: function (scope) {
            },
          },
          screen_num: {label: "切屏数量", prop: "screen_num"},
          exam_late: {
            label: "迟到限制",
            prop: "exam_late",
            type: "switch",
            activeValue: true,
            inactiveValue: false,
            switchChage: function (scope) {
            },
          },
          late_time: {label: "最晚进入考试时间", prop: "late_time"},
          exam_shor: {
            label: "最短答题",
            prop: "exam_shor",
            type: "switch",
            activeValue: true,
            inactiveValue: false,
            switchChage: function (scope) {
            },
          },
          shor_time: {label: "最短答题时间", prop: "shor_time"},
          exam_tian: {
            label: "填空题手工批改",
            prop: "exam_tian",
            type: "switch",
            activeValue: true,
            inactiveValue: false,
            switchChage: function (scope) {
            },
          },
          start_time: {
            label: "考试开始时间",
            prop: "start_time",
          },
          end_time: {label: "考试结束时间", prop: "end_time"},
          status: {
            label: "状态",
            prop: "status",
            type: "switch",
            activeValue: true,
            inactiveValue: false,
            switchChage: function (scope) {
            },
          },
          create_at: {label: "创建时间", prop: "create_time", order: true},
          button: {
            label: "操作",
            width: "130",
            type: "func",
            fixed: true,
            options: [{
              label: '预览', handle: function (scope) {
                _this.searchTopic(scope['row'])
                _this.previewExam = true;
              }
            }],
            edit: function (scope) {
              _this.row = scope['row'];
              _this.alertTitle = '编辑'
              _this.dialogVisible = true;
              let data = [];
              data.push(scope['row']['coverImg']);
              setTimeout(() => {
                if (scope['row']['chop_screen']) {
                  _this.fapi.getRule('screen_num').props.disabled = false;
                }
                if (scope['row']['exam_late']) {
                  _this.fapi.getRule('late_time').props.disabled = false;
                }
                if (scope['row']['exam_shor']) {
                  _this.fapi.getRule('shor_time').props.disabled = false;
                }
                Object.keys(scope['row']).forEach((item) =>{
                  _this.fapi.setValue(item, scope['row'][item]);
                })
                _this.setFormDisplay(scope['row']['pattern']);
              }, 0)

            },
            del: function (scope) {
              _this.deleteExamSend(scope['row']['id']);
            },
          },
        },
      },
    }
  },
  watch: {
    dialogVisible(newValue) {
      if (!newValue) {
        _this.fapi.resetFields(); //清空数据
      }
    },
    previewExam(newValue) {
      if (!newValue) {
        _this.perViewData = {
          dan: [],
          duo: [],
          pan: [],
          tian: [],
          jianda: [],
          saoma: [],
          read: [],
        }; //清空数据
      }
    }
  },
  methods: {

    /**
     * 设置标题是否显示
     */
    setFormDisplay(e) {
      if (e == '作业') {
        _this.fapi.display(false, 'exam_num')
        _this.fapi.display(false, 'duration')
        _this.fapi.display(false, 'face')
        _this.fapi.display(false, 'video_monitor')
        _this.fapi.display(false, 'exam_model')
        _this.fapi.display(false, 'chop_screen')
        _this.fapi.display(false, 'screen_num')
        _this.fapi.display(false, 'late_time')
        _this.fapi.display(false, 'exam_shor')
        _this.fapi.display(false, 'shor_time')
        _this.fapi.display(false, 'exam_late')
      } else {
        _this.fapi.display(true, 'exam_num')
        _this.fapi.display(true, 'duration')
        _this.fapi.display(true, 'face')
        _this.fapi.display(true, 'video_monitor')
        _this.fapi.display(true, 'exam_model')
        _this.fapi.display(true, 'chop_screen')
        _this.fapi.display(true, 'screen_num')
        _this.fapi.display(true, 'late_time')
        _this.fapi.display(true, 'exam_shor')
        _this.fapi.display(true, 'shor_time')
        _this.fapi.display(true, 'exam_late')
      }
    },

    /**
     * 搜索题目
     */
    searchTopic: function (val) {
      console.log(val)
      this.$store.dispatch('exam/searchPaperTopic', {
        id: val['paper_id']
      }).then((res) => {
        const {data} = res;
        if (data) {
          let dan = [];
          let duo = [];
          let pan = [];
          let tian = [];
          let jianda = [];
          let saoma = [];
          let read = [];
          _this.perViewData = {};
          data.forEach((item, index) => {
            if (item.type == '单选题') {
              dan.push(item);
            } else if (item.type == '多选题') {
              duo.push(item)
            } else if (item.type == '判断题') {
              pan.push(item)
            } else if (item.type == '填空题') {
              tian.push(item)
            } else if (item.type == '简答题') {
              jianda.push(item)
            } else if (item.type == '扫码题') {
              saoma.push(item)
            } else if (item.type == '阅读题') {
              read.push(item)
            }
          })
          _this.perViewData = {
            dan: dan,
            duo: duo,
            pan: pan,
            tian: tian,
            jianda: jianda,
            saoma: saoma,
            read: read,
          }
          console.log(this.perViewData)

        }
      })
    },
    resetForm: function () {
      _this.searchParams = {};
    },
    pagerSelect: function (val) {
      if (val) {
        let options = _this.rule[1].options;
        let data = options.find((item) => {
          return item.id === val;
        })
        _this.fapi.setValue('total_score', data.score);
      }
    },

    /**
     * 查询课程数据
     */
    getClassList: function (page = 1, title) {
      _this.selectClass = true;
      _this.$store
          .dispatch("office/getClassSelectList", {
            page: page,
            title: title,
          })
          .then((res) => {
            _this.selectClass = false;
            _this.rule[0].options.length = 0;
            res.data.data.forEach((item) => {
              let obj = {
                id: item.id,
                title: item.title,
              }
              _this.rule[0].options.push(obj);
            })
            this.pageSizes.classPage.currentPage = res.data.current_page;
            this.pageSizes.classPage.total = res.data.total;

          });
    },

    /**
     * 获取考试列表数据
     */
    getPaperList: function (page = 1, title) {
      _this.selectPaper = true;
      _this.$store
          .dispatch("exam/getPaperList", {
            title: title,
            page: page,
          })
          .then(() => {
            _this.selectPaper = false;
            let data = this.$store.state.exam.paperList;
            _this.rule[1].options.length = 0;
            data.data.forEach((item, index) => {
              let obj = {
                id: item.id,
                score: item.score,
                title: item.title,
              }
              _this.rule[1].options.push(obj);
            })
            _this.pageSizes.paperPage.currentPage = data.current_page;
            _this.pageSizes.paperPage.total = data.total;

          });
    },

    classCurrentChange: function (val) {
      _this.getClassList(val);
    },
    paperCurrentChange: function (val) {
      _this.getPaperList(val);
    },

    classClear: function () {
      _this.getClassList();
    },
    paperClear: function () {
      _this.fapi.setValue('total_score', 0);
      _this.getPaperList();
    },

    classFilterMethod: function (val) {
      _this.getClassList(1, val);
    },
    paperFilterMethod: function (val) {
      _this.getPaperList(1, val);
    },

    onSubmit: function (val) {
      _this.createOrUpdate(val)
    },

    searchForm: function (val) {
      _this.searchParams = val;
      _this.getDataList(val);
    },
    handleHeardDel: function (val) {
      let data = [];
      val.forEach((item, index) => {
        data.push(item.id)
      })
      _this.deleteExamSend(data);

    },
    handlePaginationCurrentChange: function (val) {
      _this.loading = true;
      _this.pagination["currentPage"] = val;
      _this.getDataList(_this.searchParams);

    },
    handlePaginationSizeChange: function (val) {
      _this.loading = true;
      _this.pagination["pageSize"] = val;
      _this.getDataList(_this.searchParams);
    },
    handleAdd: function (val) {
      this.alertTitle = '添加';
      this.dialogVisible = true;
      this.row = null;
    },
    getDataList: function (param) {
      _this.loading = true;
      _this.$store
          .dispatch("exam/getExamSendList", param ? {
            title: param['title'],
            pattern: param['pattern'],
            page: _this.pagination["currentPage"],
            pageSize: _this.pagination["pageSize"],
          } : {
            page: _this.pagination["currentPage"],
            pageSize: _this.pagination["pageSize"],
          })
          .then(() => {
            _this.loading = false;
            _this.dialogVisible = false;
            let data = this.$store.state.exam.examSendList;
            _this.tableData = data.data;
            _this.pagination["currentPage"] = data["current_page"];
            _this.pagination["total"] = data["total"];
          });
    },
    createMajor: function (param) {
      _this.$store
          .dispatch("portal/addMajorList", {
            title: param["title"],
            status: param["status"],
            content: param['content'],
            coverImg: param["coverImg"],
          })
          .then((res) => {
            const {data, msg} = res;
            if (data) {
              _this.$message.success(msg);
              _this.getDataList();
            } else {
              _this.$message.error(msg);
            }
          });
    },
    createOrUpdate: function (param) {
      _this.$store
          .dispatch("exam/createExamSendOrUpdate", {
            id: _this.row == null ? '' : _this.row.id,
            ...param
          })
          .then((res) => {
            const {data, msg} = res;
            if (data) {
              _this.$message.success(msg);
              _this.getDataList();
            } else {
              _this.$message.error(msg);
            }
          });
    },
    deleteExamSend: function (val) {
      _this.$store
          .dispatch("exam/deleteExamSend", {
            id: val,
          })
          .then((res) => {
            const {data, msg} = res;
            if (data) {
              _this.getDataList();
              _this.$message.success(msg);
              return;
            }
            return _this.$message.error(msg);
          });
    },


  }
  ,
  created() {
    _this = this;
    _this.getDataList();
    _this.getClassList()
    _this.getPaperList()
  }
}
</script>

<style scoped>

</style>
